package com.example.danangtravel;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class Tbshopping_activity extends TabActivity {
	public TabHost tabHost;
	public Resources res;
	public ImageButton btnhome;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tbshopping_activity);
		btnhome = (ImageButton) findViewById(R.id.btnhom);
		btnhome.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				finish();
			}
		});

		setTabs();
		// res = getResources();
		// tabHost = getTabHost();
		// TabHost.TabSpec spec;
		//
		// Intent intent;
		// intent = new Intent().setClass(this, Tbshopping_thsieuthi.class);
		// spec = tabHost
		// .newTabSpec("")
		// .setIndicator("Siêu thị",
		// res.getDrawable(R.drawable.tab_home))
		// .setContent(intent);
		// tabHost.addTab(spec);
		//
		// intent = new Intent().setClass(this, Tbshopping_thcho.class);
		// spec = tabHost.newTabSpec("")
		// .setIndicator("Chợ", res.getDrawable(R.drawable.tab_search))
		// .setContent(intent);
		// tabHost.addTab(spec);
		//
		// intent = new Intent().setClass(this, Tbshopping_thcuahang.class);
		// spec = tabHost
		// .newTabSpec("")
		// .setIndicator("Cửa hàng",
		// res.getDrawable(R.drawable.tab_home))
		// .setContent(intent);
		// tabHost.addTab(spec);
		//
		// tabHost.setCurrentTab(0);

	}

	private void setTabs() {
		addTab("Siêu thị", R.drawable.tab_sieuthi, Tbshopping_thsieuthi.class);
		addTab("Chợ", R.drawable.tab_cho, Tbshopping_thcho.class);

		addTab("Cửa hàng", R.drawable.tab_cuahang, Tbshopping_thcuahang.class);
	}

	private void addTab(String labelId, int drawableId, Class<?> c) {
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);

		View tabIndicator = LayoutInflater.from(this).inflate(
				R.layout.tab_indicator, getTabWidget(), false);
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);

		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}

}
